

#define DSG_TEMPERATURE_TABLE_SECTIONS      4
#define RESIDUAL_DSG_1st_TEMPERATURE_INDEX  0
#define RESIDUAL_DSG_2nd_TEMPERATURE_INDEX  1
#define RESIDUAL_DSG_3rd_TEMPERATURE_INDEX  2
#define RESIDUAL_DSG_4th_TEMPERATURE_INDEX  3



#define DSG_OCV_TABLE_POINTS 41
#define DSG_NUM_OF_OCV_LINE  7

#define RESIDUAL_DSG_CAPACITY_INDEX     0
#define RESIDUAL_DSG_1st_CURRENT_INDEX  1
#define RESIDUAL_DSG_2nd_CURRENT_INDEX  2
#define RESIDUAL_DSG_3rd_CURRENT_INDEX  3
#define RESIDUAL_DSG_4th_CURRENT_INDEX  4
#define RESIDUAL_DSG_5th_CURRENT_INDEX  5
#define RESIDUAL_DSG_6th_CURRENT_INDEX  6
#define RESIDUAL_DSG_7th_CURRENT_INDEX  7


/*
; TERMINAL_VOLTAGE units is mV
; RESIDUAL_CAPACITY units is percentage
; Please sort from largest to smallest
// 2600mAh cell
*/

const unsigned int DSG_TEMPERATURE_OCVTable[DSG_TEMPERATURE_TABLE_SECTIONS][DSG_OCV_TABLE_POINTS][DSG_NUM_OF_OCV_LINE+1] =
{
    {// 1st Dim
        ////////////// RESIDUAL CAPACITY  at -5 degrees /////////////////////////////////////////////////////////////////////////////////////////////////
        //  Capacity,           1st mV              2nd mV              3rd mV          4th mV          5th mV              6th mV          7th mV
        ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        //Current-5.2Ah,2P      <= 3.3A             3.4~4.7A          4.6~6.0A          6.0~7.5A         7.6~8.7A         8.8~10.0A        >10.0A        
        //  SOC%,                 Pack V,           Pack V,           Pack V,           Pack V,            Pack V,         Pack V,            Pack V,
        ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        {    10000   ,          29275,              29275,            29275,            29275,           29275,            29275,          29275    },    // index = 00 
        {    9750    ,          27016,              26579,            26067,            25739,           25536,            25318,          25118    },    // index = 01 
        {    9500    ,          26610,              26123,            25564,            25236,           24964,            24709,          24509    },    // index = 02 
        {    9250    ,          26459,              25968,            25412,            25120,           24816,            24563,          24363    },    // index = 03 
        {    9000    ,          26306,              25818,            25269,            24976,           24673,            24429,          24229    },    // index = 04 
        {    8750    ,          26151,              25670,            25134,            24804,           24533,            24305,          24105    },    // index = 05 
        {    8500    ,          25998,              25524,            24995,            24635,           24397,            24178,          23978    },    // index = 06 
        {    8250    ,          25855,              25382,            24842,            24484,           24288,            24031,          23831    },    // index = 07 
        {    8000    ,          25712,              25241,            24690,            24334,           24183,            23883,          23683    },    // index = 08 
        {    7750    ,          25576,              25097,            24548,            24194,           24058,            23744,          23544    },    // index = 09 
        {    7500    ,          25443,              24952,            24411,            24060,           23916,            23613,          23413    },    // index = 10 
        {    7250    ,          25308,              24811,            24278,            23931,           23771,            23492,          23292    },    // index = 11 
        {    7000    ,          25170,              24675,            24149,            23812,           23636,            23387,          23187    },    // index = 12 
        {    6750    ,          25030,              24543,            24023,            23701,           23513,            23298,          23098    },    // index = 13 
        {    6500    ,          24901,              24423,            23907,            23589,           23389,            23204,          23004    },    // index = 14 
        {    6250    ,          24782,              24315,            23802,            23477,           23266,            23092,          22892    },    // index = 15 
        {    6000    ,          24668,              24209,            23700,            23366,           23142,            22976,          22776    },    // index = 16 
        {    5750    ,          24565,              24106,            23603,            23259,           23040,            22864,          22664    },    // index = 17 
        {    5500    ,          24469,              24004,            23509,            23156,           22959,            22755,          22555    },    // index = 18 
        {    5250    ,          24378,              23909,            23417,            23058,           22879,            22648,          22448    },    // index = 19 
        {    5000    ,          24302,              23833,            23332,            22986,           22801,            22553,          22353    },    // index = 20 
        {    4750    ,          24225,              23756,            23246,            22921,           22724,            22461,          22261    },    // index = 21 
        {    4500    ,          24159,              23691,            23178,            22851,           22652,            22388,          22188    },    // index = 22 
        {    4250    ,          24096,              23629,            23114,            22779,           22585,            22330,          22130    },    // index = 23 
        {    4000    ,          23973,              23487,            22947,            22589,           22399,            22154,          21954    },    // index = 24 
        {    3750    ,          23921,              23436,            22896,            22523,           22331,            22089,          21889    },    // index = 25 
        {    3500    ,          23872,              23387,            22848,            22463,           22259,            22015,          21815    },    // index = 26 
        {    3250    ,          23820,              23332,            22795,            22405,           22190,            21942,          21742    },    // index = 27 
        {    3000    ,          23764,              23271,            22740,            22359,           22142,            21880,          21680    },    // index = 28 
        {    2750    ,          23709,              23211,            22679,            22313,           22095,            21818,          21618    },    // index = 29 
        {    2500    ,          23654,              23152,            22611,            22257,           22031,            21752,          21552    },    // index = 30 
        {    2250    ,          23600,              23093,            22539,            22193,           21953,            21683,          21482    },    // index = 31 
        {    2000    ,          23543,              23034,            22465,            22124,           21872,            21610,          21416    },    // index = 32 
        {    1750    ,          23480,              22971,            22389,            22038,           21787,            21526,          21349    },    // index = 33 
        {    1500    ,          23417,              22909,            22312,            21945,           21700,            21434,          21282    },    // index = 34 
        {    1250    ,          23336,              22816,            22201,            21845,           21595,            21363,          21235    },    // index = 35 
        {    1000    ,          23252,              22718,            22085,            21739,           21468,            21284,          21179    },    // index = 36 
        {    750     ,          23143,              22582,            21916,            21608,           21261,            21205,          21142    },    // index = 37 
        {    500     ,          23007,              22405,            21691,            21423,           21192,            21125,          21125    },    // index = 38 
        {    250     ,          22389,              21818,            21417,            21306,           21106,            21046,          21075    },    // index = 39 
        {    0       ,          21000,              21000,            21000,            21000,           21000,            21000,          21000    }     // index = 40 
    },// 1st Dim

    {// 2nd Dim
        ////////////// RESIDUAL CAPACITY  at   5 degrees /////////////////////////////////////////////////////////////////////////////////////////////////
        //  Capacity,           1st mV              2nd mV              3rd mV          4th mV          5th mV              6th mV          7th mV
        ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        //Current-5.2Ah,2P      <= 3.3A             3.4~4.7A          4.6~6.0A          6.0~7.5A         7.6~8.7A         8.8~10.0A        >10.0A        
        //  SOC%,                 Pack V,           Pack V,           Pack V,           Pack V,            Pack V,         Pack V,            Pack V,
        ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        {    10000   ,              29275,            29275,            29275,           29275,            29275,          29275,          29275},    // index = 00 
        {    9750    ,              27296,            26894,            26487,           26124,            25921,          25703,          25503},    // index = 01 
        {    9500    ,              26890,            26438,            25984,           25621,            25349,          25094,          24894},    // index = 02 
        {    9250    ,              26739,            26283,            25832,           25505,            25201,          24948,          24748},    // index = 03 
        {    9000    ,              26586,            26133,            25689,           25361,            25058,          24814,          24614},    // index = 04 
        {    8750    ,              26431,            25985,            25554,           25189,            24918,          24690,          24490},    // index = 05 
        {    8500    ,              26278,            25839,            25415,           25020,            24782,          24563,          24363},    // index = 06 
        {    8250    ,              26135,            25697,            25262,           24869,            24673,          24416,          24216},    // index = 07 
        {    8000    ,              25992,            25556,            25110,           24719,            24568,          24268,          24068},    // index = 08 
        {    7750    ,              25856,            25412,            24968,           24579,            24443,          24129,          23929},    // index = 09 
        {    7500    ,              25723,            25267,            24831,           24445,            24301,          23998,          23798},    // index = 10 
        {    7250    ,              25588,            25126,            24698,           24316,            24156,          23877,          23677},    // index = 11 
        {    7000    ,              25450,            24990,            24569,           24197,            24021,          23772,          23572},    // index = 12 
        {    6750    ,              25310,            24858,            24443,           24086,            23898,          23683,          23483},    // index = 13 
        {    6500    ,              25181,            24738,            24327,           23974,            23774,          23589,          23389},    // index = 14 
        {    6250    ,              25062,            24630,            24222,           23862,            23651,          23477,          23277},    // index = 15 
        {    6000    ,              24948,            24524,            24120,           23751,            23527,          23361,          23161},    // index = 16 
        {    5750    ,              24845,            24421,            24023,           23644,            23425,          23249,          23049},    // index = 17 
        {    5500    ,              24749,            24319,            23929,           23541,            23344,          23140,          22940},    // index = 18 
        {    5250    ,              24658,            24224,            23837,           23443,            23264,          23033,          22833},    // index = 19 
        {    5000    ,              24582,            24148,            23752,           23371,            23186,          22938,          22738},    // index = 20 
        {    4750    ,              24505,            24071,            23666,           23306,            23109,          22846,          22646},    // index = 21 
        {    4500    ,              24439,            24006,            23598,           23236,            23037,          22773,          22573},    // index = 22 
        {    4250    ,              24376,            23944,            23534,           23164,            22970,          22715,          22515},    // index = 23 
        {    4000    ,              24281,            23834,            23409,           23013,            22823,          22577,          22377},    // index = 24 
        {    3750    ,              24229,            23783,            23358,           22947,            22754,          22512,          22312},    // index = 25 
        {    3500    ,              24180,            23733,            23310,           22887,            22683,          22438,          22238},    // index = 26 
        {    3250    ,              24128,            23678,            23257,           22829,            22613,          22366,          22166},    // index = 27 
        {    3000    ,              24072,            23618,            23202,           22782,            22565,          22303,          22103},    // index = 28 
        {    2750    ,              24017,            23557,            23141,           22736,            22518,          22241,          22041},    // index = 29 
        {    2500    ,              23962,            23498,            23073,           22680,            22454,          22176,          21976},    // index = 30 
        {    2250    ,              23908,            23440,            23001,           22617,            22377,          22107,          21907},    // index = 31 
        {    2000    ,              23851,            23380,            22927,           22548,            22295,          22034,          21834},    // index = 32 
        {    1750    ,              23788,            23318,            22851,           22461,            22211,          21949,          21749},    // index = 33 
        {    1500    ,              23725,            23256,            22774,           22368,            22124,          21858,          21658},    // index = 34 
        {    1250    ,              23644,            23163,            22663,           22268,            22019,          21744,          21544},    // index = 35 
        {    1000    ,              23560,            23065,            22547,           22162,            21891,          21606,          21406},    // index = 36 
        {    750     ,              23451,            22929,            22378,           22032,            21684,          21383,          21223},    // index = 37 
        {    500     ,              23315,            22752,            22153,           21847,            21405,          21245,          21149},    // index = 38 
        {    250     ,              22697,            22164,            21599,           21450,            21215,          21167,          21117},    // index = 39 
        {    0       ,              21000,            21000,            21000,           21000,            21000,          21000,          21000}     // index = 40 
    },// 2nd Dim

    {// 3rd Dim
        ////////////// RESIDUAL CAPACITY  at 15 degrees /////////////////////////////////////////////////////////////////////////////////////////////////
        //  Capacity,           1st mV              2nd mV              3rd mV          4th mV          5th mV              6th mV          7th mV
        ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        //Current-5.2Ah,2P      <= 3.3A             3.4~4.7A          4.6~6.0A          6.0~7.5A         7.6~8.7A         8.8~10.0A        >10.0A        
        //  SOC%,                 Pack V,           Pack V,           Pack V,           Pack V,            Pack V,         Pack V,            Pack V,
        ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        {    10000   ,            29275,            29275,            29275,           29275,            29275,          29275,            29275  },    // index = 00 
        {    9750    ,            27419,            27058,            26682,           26329,            26148,          25942,            25742  },    // index = 01 
        {    9500    ,            27021,            26618,            26201,           25831,            25599,          25358,            25158  },    // index = 02 
        {    9250    ,            26866,            26458,            26043,           25697,            25447,          25203,            25003  },    // index = 03 
        {    9000    ,            26713,            26302,            25891,           25556,            25301,          25055,            24855  },    // index = 04 
        {    8750    ,            26560,            26150,            25746,           25399,            25156,          24915,            24715  },    // index = 05 
        {    8500    ,            26409,            26002,            25606,           25234,            25007,          24776,            24576  },    // index = 06 
        {    8250    ,            26263,            25856,            25459,           25078,            24871,          24627,            24427  },    // index = 07 
        {    8000    ,            26119,            25713,            25312,           24930,            24752,          24486,            24286  },    // index = 08 
        {    7750    ,            25980,            25570,            25171,           24789,            24624,          24353,            24153  },    // index = 09 
        {    7500    ,            25844,            25432,            25032,           24650,            24486,          24221,            24021  },    // index = 10 
        {    7250    ,            25708,            25301,            24896,           24515,            24343,          24091,            23891  },    // index = 11 
        {    7000    ,            25572,            25172,            24763,           24388,            24207,          23970,            23770  },    // index = 12 
        {    6750    ,            25437,            25043,            24635,           24274,            24083,          23865,            23665  },    // index = 13 
        {    6500    ,            25307,            24920,            24514,           24164,            23961,          23759,            23559  },    // index = 14 
        {    6250    ,            25187,            24803,            24403,           24051,            23846,          23646,            23446  },    // index = 15 
        {    6000    ,            25070,            24686,            24294,           23938,            23733,          23534,            23334  },    // index = 16 
        {    5750    ,            24964,            24580,            24193,           23831,            23632,          23427,            23227  },    // index = 17 
        {    5500    ,            24868,            24484,            24099,           23728,            23541,          23326,            23126  },    // index = 18 
        {    5250    ,            24778,            24394,            24010,           23632,            23453,          23230,            23030  },    // index = 19 
        {    5000    ,            24702,            24319,            23929,           23559,            23374,          23148,            22948  },    // index = 20 
        {    4750    ,            24628,            24246,            23851,           23495,            23300,          23072,            22872  },    // index = 21 
        {    4500    ,            24564,            24180,            23785,           23429,            23234,          23002,            22802  },    // index = 22 
        {    4250    ,            24505,            24118,            23724,           23361,            23175,          22939,            22739  },    // index = 23 
        {    4000    ,            24415,            24012,            23605,           23218,            23039,          22804,            22604  },    // index = 24 
        {    3750    ,            24365,            23962,            23554,           23157,            22977,          22752,            22552  },    // index = 25 
        {    3500    ,            24317,            23913,            23505,           23101,            22912,          22698,            22498  },    // index = 26 
        {    3250    ,            24268,            23863,            23455,           23050,            22849,          22629,            22429  },    // index = 27 
        {    3000    ,            24218,            23811,            23403,           23007,            22799,          22559,            22359  },    // index = 28 
        {    2750    ,            24168,            23757,            23348,           22959,            22751,          22494,            22294  },    // index = 29 
        {    2500    ,            24117,            23703,            23288,           22900,            22696,          22430,            22230  },    // index = 30 
        {    2250    ,            24065,            23647,            23225,           22836,            22632,          22365,            22165  },    // index = 31 
        {    2000    ,            24011,            23588,            23159,           22769,            22560,          22294,            22094  },    // index = 32 
        {    1750    ,            23952,            23526,            23088,           22692,            22482,          22214,            22014  },    // index = 33 
        {    1500    ,            23883,            23453,            23011,           22602,            22393,          22118,            21918  },    // index = 34 
        {    1250    ,            23798,            23359,            22906,           22500,            22285,          22003,            21803  },    // index = 35 
        {    1000    ,            23695,            23243,            22786,           22377,            22142,          21850,            21650  },    // index = 36 
        {    750     ,            23564,            23092,            22617,           22219,            21934,          21631,            21431  },    // index = 37 
        {    500     ,            23241,            22745,            22315,           21920,            21474,          21196,            21226  },    // index = 38 
        {    250     ,            22292,            21832,            21577,           21400,            21285,          21113,            21130  },    // index = 39 
        {    0       ,            21000,            21000,            21000,           21000,            21000,          21000,            21000  }     // index = 40 
    },// 3rd Dim


    {// 4th Dim
        ////////////// RESIDUAL CAPACITY  at 25 degrees /////////////////////////////////////////////////////////////////////////////////////////////////
        //  Capacity,           1st mV              2nd mV              3rd mV          4th mV          5th mV              6th mV          7th mV
        ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        //Current-5.2Ah,2P      <= 3.3A             3.4~4.7A          4.6~6.0A          6.0~7.5A         7.6~8.7A         8.8~10.0A        >10.0A        
        //  SOC%,                 Pack V,           Pack V,           Pack V,           Pack V,            Pack V,         Pack V,            Pack V,
        ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        {    10000   ,            29275,            29275,            29275,          29275,             29275,          29275,            29275 },    // index = 00 
        {    9750    ,            27613,            27326,            27017,          26710,             26479,          26215,            26015 },    // index = 01 
        {    9500    ,            27222,            26902,            26559,          26216,             25954,          25657,            25457 },    // index = 02 
        {    9250    ,            27063,            26737,            26394,          26064,             25798,          25492,            25292 },    // index = 03 
        {    9000    ,            26910,            26577,            26234,          25926,             25650,          25332,            25132 },    // index = 04 
        {    8750    ,            26759,            26420,            26079,          25783,             25500,          25175,            24975 },    // index = 05 
        {    8500    ,            26610,            26269,            25936,          25624,             25338,          25023,            24823 },    // index = 06 
        {    8250    ,            26460,            26119,            25796,          25461,             25175,          24872,            24672 },    // index = 07 
        {    8000    ,            26317,            25975,            25655,          25315,             25040,          24740,            24540 },    // index = 08 
        {    7750    ,            26174,            25833,            25514,          25173,             24910,          24613,            24413 },    // index = 09 
        {    7500    ,            26035,            25702,            25373,          25031,             24775,          24479,            24279 },    // index = 10 
        {    7250    ,            25899,            25581,            25233,          24889,             24635,          24340,            24140 },    // index = 11 
        {    7000    ,            25764,            25459,            25096,          24754,             24497,          24204,            24004 },    // index = 12 
        {    6750    ,            25633,            25334,            24967,          24638,             24373,          24081,            23881 },    // index = 13 
        {    6500    ,            25504,            25208,            24841,          24528,             24253,          23963,            23763 },    // index = 14 
        {    6250    ,            25381,            25081,            24723,          24415,             24147,          23851,            23651 },    // index = 15 
        {    6000    ,            25261,            24953,            24608,          24301,             24045,          23741,            23541 },    // index = 16 
        {    5750    ,            25153,            24844,            24503,          24192,             23945,          23640,            23440 },    // index = 17 
        {    5500    ,            25057,            24753,            24409,          24091,             23844,          23548,            23348 },    // index = 18 
        {    5250    ,            24969,            24670,            24323,          23996,             23747,          23462,            23262 },    // index = 19 
        {    5000    ,            24892,            24596,            24246,          23922,             23667,          23393,            23193 },    // index = 20 
        {    4750    ,            24821,            24525,            24176,          23860,             23596,          23332,            23132 },    // index = 21 
        {    4500    ,            24760,            24460,            24113,          23797,             23537,          23266,            23066 },    // index = 22 
        {    4250    ,            24703,            24397,            24055,          23732,             23486,          23197,            22997 },    // index = 23 
        {    4000    ,            24626,            24306,            23955,          23615,             23371,          23070,            22870 },    // index = 24 
        {    3750    ,            24577,            24256,            23903,          23560,             23315,          23030,            22830 },    // index = 25 
        {    3500    ,            24531,            24209,            23854,          23508,             23257,          22996,            22796 },    // index = 26 
        {    3250    ,            24486,            24164,            23806,          23463,             23201,          22932,            22732 },    // index = 27 
        {    3000    ,            24441,            24120,            23758,          23423,             23148,          22853,            22653 },    // index = 28 
        {    2750    ,            24395,            24073,            23709,          23373,             23098,          22784,            22584 },    // index = 29 
        {    2500    ,            24348,            24023,            23657,          23313,             23052,          22723,            22523 },    // index = 30 
        {    2250    ,            24299,            23969,            23603,          23248,             23002,          22661,            22461 },    // index = 31 
        {    2000    ,            24247,            23911,            23544,          23182,             22941,          22592,            22392 },    // index = 32 
        {    1750    ,            24193,            23849,            23480,          23115,             22870,          22517,            22317 },    // index = 33 
        {    1500    ,            24118,            23765,            23402,          23028,             22777,          22417,            22217 },    // index = 34 
        {    1250    ,            24030,            23670,            23304,          22924,             22667,          22301,            22101 },    // index = 35 
        {    1000    ,            23908,            23536,            23179,          22784,             22509,          22134,            21934 },    // index = 36 
        {    750     ,            23755,            23370,            23011,          22599,             22299,          21917,            21717 },    // index = 37 
        {    500     ,            23243,            22853,            22631,          22186,             21867,          21501,            21301 },    // index = 38 
        {    250     ,            21963,            21616,            21708,          21263,             21580,          21293,            21193 },    // index = 39 
        {    0       ,            21000,            21000,            21000,          21000,             21000,          21000,            21000 }     // index = 40 
    },// 4th Dim

};

